package com.dundun.pattern.flyweight;

import java.io.BufferedReader;
import java.io.FileReader;

public class BigChar {

    private char charname;
    private String fontdata;

    public BigChar(char charname) {
        this.charname = charname;
        try {
            BufferedReader reader = new BufferedReader(
                    new FileReader("big" + charname + ".txt")
            );
            String line;
            StringBuilder sb = new StringBuilder();
            while ((line=reader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            reader.close();
            fontdata = sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            fontdata = charname + "?";
        }
    }

    public void print() {
        System.out.println(fontdata);
    }
}